<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html lang="en">
<head>
<base href="<%=basePath%>">

<title></title>
<meta charset="UTF-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">

<link rel="stylesheet" type="text/css"
	href="js/zTree_v3/css/zTreeStyle/zTreeStyle.css">
<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
<script type="text/javascript" src="js/layer/layer.js"></script>
<script type="text/javascript"
	src="js/zTree_v3/js/jquery.ztree.core.min.js"></script>

<style type="text/css">
	html,body,div{
			margin:0;
			padding: 0;
		}
		html,body{
			width: 100%;
			height: 100%;
		}
		.wrapper{
			width: 100%;
			height: 100%;
			position: relative;
			
		}
		.cont-left{
			top: 0;
			bottom: 0;
			position: absolute;
			width: 250px;
		}
		.cont-left{
			
		}
		.cont-right{
			 width:auto;
			 padding-left:250px;
			 height:100%;
			/*left:250px;
			position:absolute; */
		}
		.iframe-right{
			height: 100%;
			width: 100%;
			display: block;
		}

</style>

<script type="text/javascript">
	var zTreeObj;
	var thisNode;//当前选中节点
	var setting = {
		view:{
			showIcon: false
		},
		callback: {
			onClick: chooseNodes
		}
		
	};
	var zNodes =  [
		{
			name: "增值电信年报", 
			open:true,
			children: [
				{
					name: "企业级基本情况",
					children:[
						{
							name:"企业基本情况表",
							url:"ReportServer?reportlet=ZR/save/%E4%BC%81%E4%B8%9A%E5%9F%BA%E6%9C%AC%E6%83%85%E5%86%B51.cpt&op=write&masterId=${requestScope.masterId}",
							target:"myIframe"
						}
					]
				},
				{
					name: "企业服务质量",
					children:[
						{
							name:"企业服务质量表",
							url:"ReportServer?reportlet=ZR/save/%E4%BC%81%E4%B8%9A%E6%9C%8D%E5%8A%A1%E8%B4%A8%E9%87%8F.cpt&op=write&masterId=${requestScope.masterId}",
							target:"myIframe"
						}
					]
				},
				{
					name: "企业经济效益",
					children:[
						{
							name:"企业经济效益表",
							url:"ReportServer?reportlet=ZR/save/%E4%BC%81%E4%B8%9A%E7%BB%8F%E6%B5%8E%E6%95%88%E7%9B%8A(%E7%BB%8F%E6%B5%8E%E6%95%88%E7%9B%8A%E6%8C%87%E6%A0%87%E7%94%B1%E4%BC%81%E4%B8%9A%E9%80%89%E6%8B%A9%E6%98%AF%E5%90%A6%E5%85%AC%E7%A4%BA).cpt&op=write&masterId=${requestScope.masterId}",
							target:"myIframe"
						}
					]
				},
				{
					name: "网络信息安全",
					children:[
						{
							name:"网络信息安全表",
							url:"ReportServer?reportlet=ZR/save/%E7%BD%91%E7%BB%9C%E4%BF%A1%E6%81%AF%E5%AE%89%E5%85%A8_new.cpt&op=write&masterId=${requestScope.masterId}",
							target:"myIframe"
						}
					]
				},
				{
					name: "业务发展情况"
				}
			]
		}
	];
	$(document).ready(function() {
		zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
		//确定选择节点
		$("#btnOk").click(function(){
			myAddNodes();
		});
		getToAjaxNodes();
	});
	
	//选择添加节点
	function chooseNodes(event,treeId,treeNode){
		 if(treeNode.name=="业务发展情况"){
		 	thisNode=treeNode;
			layer.open({
			  type: 1,
			  area: ['800px', '400px'], //宽高
			  content: $("#nodesTemplate")
			});
		}
	}
	//开始添加节点
	function myAddNodes(){
		//保存待添加的节点数据
		var arrNode=new Array();
		var nodes=new Array();
		$("input[type='checkbox']:checked").each(function(i,v){
			var $t=$(v);
			arrNode.push({
				name:$t.val(),
				url:$t.attr("data-url"),
				target:"myIframe"
			});
			nodes.push("{fkMaster:\"${requestScope.masterId}\",menuName:\""+$t.val()+"\",menuUrl:\""+$t.attr("data-url")+"\"}");
		});
		
		//赋值前先清空该节点下所有节点
		zTreeObj.removeChildNodes(thisNode);
		//重新赋值该节点下子节点
		zTreeObj.addNodes(thisNode,arrNode);
		setNodesData(nodes);
		//关闭layer
		layer.close(layer.index);
	}
	
	//获取菜单数据
	function getToAjaxNodes(){
		var arrNode=new Array();
		$.getJSON("menu/getMenu.do",{
			mId:'${requestScope.masterId}'
		},function(data){
			if(data&&data.length>0){
				$.each(data,function(i,v){
					arrNode.push({
						name:v.menuName,
						url:v.menuUrl,
						target:"myIframe"
					});
				});
				thisNode=thisNode||zTreeObj.getNodeByParam("name", "业务发展情况", null);
				//赋值前先清空该节点下所有节点
				zTreeObj.removeChildNodes(thisNode);
				//重新赋值该节点下子节点
				zTreeObj.addNodes(thisNode,arrNode);
			}
		});
	}
	//设置菜单数据
	function setNodesData(nodes){
		$.post("menu/setMenu.do",{
			jsonData:nodes.join(",")
		},function(data){
			alert(data.msg);
		},"json");
	}
	
	function getStatus(){
		var l=$("#licensingSelect").val();
		var y=$("#yearSelect").val();
		if(l!=""&&y!=""){
			$.getJSON("audit/getMasterStatus.do",{
				mId:'${requestScope.masterId}'
			},function(data){
				if(data){
					if(data.msg=="已报"){
						$("#backBtn").show();
						$("#subBtn").hide();
					}else if(data.msg=="未报"){
						$("#backBtn").hide();
						$("#subBtn").show();
					}
				
					$("#status").text(data.msg);
					$("#treeDemo").show(1000);
				}
			});
		}
	}
	
</script>

</head>

<body>
	
	<div class="wrapper">
		<div class="cont-left">
			<div id="treeDemo" style="display: none;" class="ztree"></div>
		</div>
		<div class="cont-right">
			<div class="right-wrapper">
				<div style="height: 20%;">
					<div>
						<label>年份选择</label>
						<select id="yearSelect" onchange="getStatus();">
							<option value="" selected="selected">请选择</option>
							<option value="2017" >2017</option>
						</select>
						
						<label>许可证选择</label>
						<select id="licensingSelect" onchange="getStatus();">
							<option value="" selected="selected">请选择</option>
							<option value="增值电信许可证">增值电信许可证</option>
						</select>
						
						<span>
							状态:
							<span id="status"></span>
						</span>
					</div>
					<div>
						<button id="subBtn" style="display: none;" >提交</button>
						<button id="backBtn" style="display: none;">收回</button>
					</div>
				</div>
				<div style="height: 80%;">
					<iframe class="iframe-right" frameborder="0" name="myIframe" ></iframe>
				</div>
			</div>
		</div>
	</div>
	<div id="nodesTemplate" style="display: none;" >
	<!-- 增值服务候选模版 -->
		<div>
			<div>
				<input type="checkbox" id="checkbox1" data-url="ReportServer?reportlet=ZR/save/%E5%9B%BD%E5%86%85%E7%94%9A%E5%B0%8F%E5%8F%A3%E5%BE%84%E7%BB%88%E7%AB%AF%E5%9C%B0%E7%90%83%E7%AB%99.cpt&op=write&masterId=${requestScope.masterId}" value="国内甚小口径终端地球站（VSAT）通信业务表">
				<label for="checkbox1" >国内甚小口径终端地球站（VSAT）通信业务表</label>
			</div>
			<div>
				<input type="checkbox" id="checkbox13" data-url="ReportServer?reportlet=ZR/save/%E5%9B%BA%E5%AE%9A%E7%BD%91%E5%9B%BD%E5%86%85%E6%95%B0%E6%8D%AE%E4%BC%A0%E9%80%81%E4%B8%9A%E5%8A%A1%E8%A1%A8.cpt&op=write&masterId=${requestScope.masterId}" value="固定网国内数据传送业务表">
				<label for="checkbox13" >固定网国内数据传送业务表</label>
			</div>
			<div>
				<input type="checkbox" id="checkbox2" data-url="ReportServer?reportlet=ZR/save/%E7%BD%91%E7%BB%9C%E6%89%98%E7%AE%A1%E4%B8%9A%E5%8A%A1%E8%A1%A8.cpt&op=write&masterId=${requestScope.masterId}" value="网络托管业务表">
				<label for="checkbox2" >网络托管业务表</label>
			</div>
			<div>
				<input type="checkbox" id="checkbox3" data-url="ReportServer?reportlet=ZR/save/%E4%BA%92%E8%81%94%E7%BD%91%E6%95%B0%E6%8D%AE%E4%B8%AD%E5%BF%83%E4%B8%9A%E5%8A%A1%E8%A1%A8.cpt&op=write&masterId=${requestScope.masterId}" value="互联网数据中心业务表">
				<label for="checkbox3" >互联网数据中心业务表</label>
			</div>
			<div>
				<input type="checkbox" id="checkbox4" data-url="ReportServer?reportlet=ZR/save/%E5%86%85%E5%AE%B9%E5%88%86%E5%8F%91%E7%BD%91%E7%BB%9C%E4%B8%9A%E5%8A%A1%E8%A1%A8.cpt&op=write&masterId=${requestScope.masterId}" value="内容分发网络业务表">
				<label for="checkbox4" >内容分发网络业务表</label>
			</div>
			<div>
				<input type="checkbox" id="checkbox5" data-url="ReportServer?reportlet=ZR/save/%E5%9B%BD%E5%86%85%E4%BA%92%E8%81%94%E7%BD%91%E8%99%9A%E6%8B%9F%E4%B8%93%E7%94%A8%E7%BD%91%E4%B8%9A%E5%8A%A1%E8%A1%A8.cpt&op=write&masterId=${requestScope.masterId}" value="国内互联网虚拟专用网业务表">
				<label for="checkbox5" >国内互联网虚拟专用网业务表</label>
			</div>
			<div>
				<input type="checkbox" id="checkbox6" data-url="ReportServer?reportlet=ZR/save/%E4%BA%92%E8%81%94%E7%BD%91%E6%8E%A5%E5%85%A5%E6%9C%8D%E5%8A%A1%E4%B8%9A%E5%8A%A1%E8%A1%A8.cpt&op=write&masterId=${requestScope.masterId}" value="互联网接入服务业务表">
				<label for="checkbox6" >互联网接入服务业务表</label>
			</div>
			<div>
				<input type="checkbox" id="checkbox7" data-url="ReportServer?reportlet=ZR/save/%E5%9C%A8%E7%BA%BF%E6%95%B0%E6%8D%AE%E5%A4%84%E7%90%86%E4%B8%8E%E4%BA%A4%E6%98%93%E5%A4%84%E7%90%86%E4%B8%9A%E5%8A%A1%E8%A1%A8.cpt&op=write&masterId=${requestScope.masterId}" value="在线数据处理与交易处理业务表">
				<label for="checkbox7" >在线数据处理与交易处理业务表</label>
			</div>
			<div>
				<input type="checkbox" id="checkbox8" data-url="ReportServer?reportlet=ZR/save/%E5%9B%BD%E5%86%85%E5%A4%9A%E6%96%B9%E9%80%9A%E4%BF%A1%E6%9C%8D%E5%8A%A1%E4%B8%9A%E5%8A%A1%E8%A1%A8.cpt&op=write&masterId=${requestScope.masterId}" value="国内多方通信服务业务表">
				<label for="checkbox8" >国内多方通信服务业务表</label>
			</div>
			<div>
				<input type="checkbox" id="checkbox9" data-url="ReportServer?reportlet=ZR/save/%E5%AD%98%E5%82%A8%E8%BD%AC%E5%8F%91%E7%B1%BB%E4%B8%9A%E5%8A%A1%E8%A1%A8.cpt&op=write&masterId=${requestScope.masterId}" value="存储转发类业务表">
				<label for="checkbox9" >存储转发类业务表</label>
			</div>
			<div>
				<input type="checkbox" id="checkbox10" data-url="ReportServer?reportlet=ZR/save/%E5%91%BC%E5%8F%AB%E4%B8%AD%E5%BF%83%E4%B8%9A%E5%8A%A1%E8%A1%A8.cpt&op=write&masterId=${requestScope.masterId}" value="呼叫中心业务表">
				<label for="checkbox10" >呼叫中心业务表</label>
			</div>
			<div>
				<input type="checkbox" id="checkbox11" data-url="ReportServer?reportlet=ZR/save/%E4%B8%9A%E5%8A%A1%E6%83%85%E5%86%B5%E8%A1%A8%E5%8D%95-%E4%BF%A1%E6%81%AF%E6%9C%8D%E5%8A%A1%EF%BC%88%E4%B8%8D%E5%90%AB%E4%BA%92%E8%81%94%E7%BD%91%E4%BF%A1%E6%81%AF%E6%9C%8D%E5%8A%A1%EF%BC%89%E4%B8%9A%E5%8A%A1%E8%A1%A8.cpt&op=write&masterId=${requestScope.masterId}" value="信息服务（不含互联网信息服务）业务表">
				<label for="checkbox11" >信息服务（不含互联网信息服务）业务表</label>
			</div>
			<div>
				<input type="checkbox" id="checkbox12" data-url="ReportServer?reportlet=ZR/save/%E4%BF%A1%E6%81%AF%E6%9C%8D%E5%8A%A1%EF%BC%88%E4%BB%85%E9%99%90%E4%BA%92%E8%81%94%E7%BD%91%E4%BF%A1%E6%81%AF%E6%9C%8D%E5%8A%A1%EF%BC%89%E4%B8%9A%E5%8A%A1%E8%A1%A8.cpt&op=write&masterId=${requestScope.masterId}" value="信息服务（仅限互联网信息服务）业务表">
				<label for="checkbox12" >信息服务（仅限互联网信息服务）业务表</label>
			</div>
			<div>
				<button id="btnOk">确认</button>
			</div>
		</div>
	</div>
</body>
</html>
